<html xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" >  

    <ui:composition template="layout.xhtml">

        <ui:define name="corpo">
            <h:form id="index_form" acceptcharset="utf-8"> 
                 <div id="breadcrumb">
                    <p:commandLink  actionListener="#{managerIndex.redirect('index.xhtml')}" value="Inicio" update="@form" immediate="true"/> >
                    <p:commandLink  actionListener="#{managerIndex.redirect('indexProtocolo.xhtml')}" value="Protocolo" update="@form" immediate="true"/> >
                    <p:commandLink  actionListener="#{managerIndex.redirect('indexLancamento.xhtml')}" value="Lançamentos" update="@form" immediate="true"/> >
                    <p:commandLink  value="Buscar" update="@form" immediate="true"/>
                </div>
                <p:messages showDetail="true" id="msg"/>
                <p:panel header="Buscar - Lançamento">
                     <h:panelGrid columns="2" id="panelGridEscolha" styleClass="textAlignRight" columnClasses="textAlignRight">
                         <f:validateBean disabled="true">
                        <h:outputLabel value="Prestador:"/>
                       
                        <p:autoComplete id="usuario" value="#{managerConsultarLancamento.usuario}" completeMethod="#{managerUsuario.completeUsuario}"  
                                            var="p" itemLabel="#{p.nome}" itemValue="#{p}" converter="usuarioConverter" forceSelection="true" converterMessage="Erro, verifique o Fornecedor" minQueryLength="3" dropdown="true" > 
                        </p:autoComplete>


                        <h:outputLabel value="Data :"/>
                        <p:calendar value="#{managerConsultarLancamento.lancamento.dataLanc}" mode="popup" showOn="both" pattern="dd/MM/yyyy" />
                        <h:outputLabel value="" />
                         </f:validateBean>
                    </h:panelGrid> 
                    <center>
                        <p:commandButton value="Consultar" icon="ui-icon-search" actionListener="#{managerConsultarLancamento.buscar()}" update="lancamentoTable, msg" />
                    </center>
                    <br/>

                    <p:dataTable id="lancamentoTable" var="lancamento" 
                                 value="#{managerConsultarLancamento.lancamentos}"
                                 paginator="true" rows="5"
                                 paginatorPosition="bottom"
                                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"  
                                 rowsPerPageTemplate="5,10,15"
                                 emptyMessage="Nenhum Registro Cadastro">  
                        <f:facet name="header">  
                            Lançamentos
                        </f:facet>
                        <p:column>  
                            <f:facet name="header" >   
                                Prestador  
                            </f:facet>  
                            <h:outputText value="#{lancamento.prestador.nome}" style="font-weight: bold" />  
                        </p:column>
                        <p:column>  
                            <f:facet name="header" >   
                                Data 
                            </f:facet>  
                            <h:outputText value="#{lancamento.dataLanc}" style="font-weight: bold">
                                 <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>
                        </p:column>                       
                        <p:column style="width: 100px;text-align: center">
                            
                            <p:commandButton actionListener="#{managerVisaoLancamento.redirect(lancamento)}" icon="ui-icon-search" title="Visualizar"/>
                            
                            <p:commandButton icon="ui-icon-trash" title="Excluir" label="Excluir" onclick="confirmDialog.show()">
                                <f:setPropertyActionListener target="#{managerLancamento.removelancamento}" value="#{lancamento}" />
                            </p:commandButton>
                            
                        </p:column>
                    </p:dataTable>
                    <p:blockUI block="lancamentoTable" trigger="lancamentoTable">  
                        CARREGANDO...<br />  
                        <p:graphicImage value="/media/img/ajax-loader.gif"/>  
                    </p:blockUI>

                </p:panel>

                 <p:confirmDialog widgetVar="confirmDialog" message="Deseja realmente excluir este registro ?" header="Confirmação de exclusão">
                    <div style="text-align: center">
                        <p:commandButton actionListener="#{managerLancamento.remover}" oncomplete="confirmDialog.hide()" value="Sim"
                                         update="lancamentoTable"/>
                        <p:commandButton onclick="confirmDialog.hide()" value="Não" />
                        
                    </div>
                </p:confirmDialog>
            </h:form>
        </ui:define>
    </ui:composition>
</html>